The present invention relates to an improved method for convecting between two color spaces, such as between RGB and YIQ color spaces.
In many applications that perform color image processing, it is necessary to convert back and forth between two color spaces. Consider the domain of color image compression as an example, although the present invention is not limited to this one application.
A typical color image compression apparatus includes a transmitting color fax machine, telephone connection, and a receiving color fax machine. At the transmitting end, the fax machine must scan the image first.
Most conventional scanning methods scan in the red, green, and blue (RGB) color space. This is usually the simplest for hardware/cost reasons. However, it has been shown in previous work that in order to compress a color image it is better to perform the compression on a color space that consists of a luminance color plane, and two color planes. Such a color space is the YIQ color space.
It turns out that the YIQ color space is superior for color image compression, because in spatial terms the rate of change of the I and Q planes is less perceptible to the human eye than say the luminance plane Y. Compression techniques take advantage of this fact, by performing simple spatial compression on the I and Q planes before any actual quantization is performed to further compact the data.
A typical example of a compression system would have the front end scanner providing a color image that yields 24 bits of data per pixel. This is normally 8 red bits, 8 green bits, and 8 blue bits. The conversion to Y,I,Q can yield three new 8 bit numbers but by combining 2 neighboring I values and 2 neighboring Q values together, the net effect is now the data is only 16 bits per pixel. Thus, 8 bits per pixel have been removed almost immediately.
More often than not the conversion form RGB to YIQ is performed in software, running on a machine such as the Motorola 68030. FIG. 1a shows the linear transformation for RGB to YIQ. Note that the numbers in the 3.times.3 matrix are not very "friendly." They are signed floating point numbers. Should the user decide to make the conversion using simple multiplication it would require 9 multiplications and 6 additions, i.e.: EQU Y =(0.299.sup.* R) +(0.587.sup.* G) +(0.114.sup.* B) - the calculation
is repeated twice more for I and Q.
Though this would prove to be the simplest in terms of code length and memory storage requirements, it is certainly not the quickest approach because of the need for the multiplications.
A very common approach used to eliminate multiplication is to use preprogrammed look-up tables. The user would premultiply all the possible R, G, B values and store them in look-up tables. Initial inspection would reveal the need for 9 separate look-up tables, each 256 entries by 16 bits wide. The possible ranges for R, G, and B are normally 0-255, stored in a single 8 bit number. However, after the linear conversion, Y has a range of 0-255 (8 bits), I has a range of +151 to -151, and Q has a range +136 to -136. To represent these values requires 9 bits instead of 8.
Because of the structure of modern microprocessor systems, once 8 bits numbers have been exceeded one normally jumps to 16 bits for the convenience of addressing purposes. Therefore, a total memory requirement now is 9.times.256.times.2 bytes or 4.5 Kbytes.
To perform the conversion, the user constructs a program that takes the R value and indexes into the Y(R) table, looks-up the value and holds it. Now take the G value, look-up the Y(G) value and add that to the Y(R) value. Finally, do the same for 0 and add to the previous total to yield the final Y value. This requires 3 look-ups and two adds. The same process is performed for I and Q, resulting in 9 look-ups and 6 adds. In comparison to above, the 9 multiplies have been replaced by 9 look-ups which are typically an order of magnitude faster than a multiply.